# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018-2019, Intel Corporation.

#
# Makefile for the Intel(R) Ethernet Connection E800 (ice.ko) driver
#

BUILD_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(BUILD_DIR)common.mk

obj-m += ice.o

ice-objs := ice_main.o		\
	ice_controlq.o		\
	ice_common.o		\
	ice_nvm.o		\
	ice_switch.o		\
	ice_sched.o		\
	ice_base.o		\
	ice_lib.o		\
	ice_txrx_lib.o		\
	ice_txrx.o		\
	ice_fltr.o		\
	ice_irq.o		\
	ice_pf_vsi_vlan_ops.o 	\
	ice_vsi_vlan_ops.o 	\
	ice_vsi_vlan_lib.o 	\
	ice_tc_lib.o		\
	ice_fdir.o		\
	ice_ethtool_fdir.o	\
	ice_acl_main.o		\
	ice_acl.o		\
	ice_acl_ctrl.o		\
	ice_vlan_mode.o		\
	ice_ddp.o		\
	ice_flex_pipe.o		\
	ice_flow.o		\
	ice_parser.o		\
	ice_imem.o		\
	ice_pg_cam.o		\
	ice_metainit.o		\
	ice_bst_tcam.o		\
	ice_ptype_mk.o		\
	ice_mk_grp.o		\
	ice_proto_grp.o		\
	ice_flg_rd.o		\
	ice_xlt_kb.o		\
	ice_parser_rt.o		\
	ice_peer_support.o	\
	ice_lag.o		\
	ice_fwlog.o		\
	ice_ieps.o		\
	ice_gnss.o		\
	ice_ethtool.o		\
	ice_idc.o		\
	kcompat.o

CFLAGS_ice_main.o := -I$(src)

ice-$(CONFIG_NET_DEVLINK:m=y) += ice_devlink.o ice_fw_update.o ice_eswitch.o ice_repr.o
ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
ice-$(CONFIG_DEBUG_FS) += ice_debugfs.o
ice-$(CONFIG_PCI_IOV) += ice_virtchnl.o ice_sriov.o ice_virtchnl_allowlist.o ice_dcf.o ice_virtchnl_fdir.o ice_virtchnl_fsub.o ice_vf_mbx.o ice_vf_vsi_vlan_ops.o ice_vf_adq.o ice_vf_lib.o
ice-$(CONFIG_PTP_1588_CLOCK:m=y) += ice_ptp.o ice_ptp_hw.o
ifndef CONFIG_PLDMFW
ice-y += kcompat_pldmfw.o
endif
#ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o

ifndef CONFIG_DIMLIB
ice-y += kcompat_dim.o kcompat_net_dim.o
endif

ifneq (${CONFIG_GNSS}, y)
ifneq (${CONFIG_GNSS}, m)
ice-y += kcompat_gnss.o
endif
endif

ifneq (${ENABLE_LM_SUPPORT},)
obj-$(CONFIG_VFIO_PCI_CORE:y=m) += ice-vfio-pci.o

ice-vfio-pci-y := ice_vfio_pci.o
ice-$(CONFIG_VFIO_PCI_CORE:m=y) += ice_migration.o
endif

ifeq (${NEED_AUX_BUS},2)
#obj-m += auxiliary.o
intel_auxiliary-objs := auxiliary.o
obj-m += intel_auxiliary.o
endif

# LM support is only enabled if the kernel has features for LM v1 protocol.
# If the kernel lacks the necessary infrastructure, LM support will be disabled.
ifeq ($(call is_kcompat_defined,HAVE_LMV1_SUPPORT),1)
export ENABLE_LM_SUPPORT := 1
endif

EXTRA_CFLAGS += -DHAVE_PF_RING
KBUILD_EXTRA_SYMBOLS=${PF_RING_PATH}/Module.symvers

KVER=$(shell uname -r)

all:
	cd ${PF_RING_PATH}/; make
	cp ${PF_RING_PATH}/Module.symvers .
	$(MAKE) -C /lib/modules/${KVER}/build M=$(PWD) modules

clean:
	$(MAKE) -C /lib/modules/${KVER}/build M=$(PWD) clean

